//
//  TableVc6+Height.swift
//  Extend
//
//  Created by 元穗 on 2017/5/25.
//  Copyright © 2017年 敬信. All rights reserved.
//


import Foundation

/// storyboard的Id持有

public protocol StoryboardIdentifiable {
    static var storyboardId: String { get };
}

/// 拓展id持有, 实现get

extension StoryboardIdentifiable where Self: UIViewController {
    public static var storyboardId: String {
        return String(describing: self);
    }
}

extension UIStoryboard {
    public func instantiateViewController<T:UIViewController>() -> T where T: StoryboardIdentifiable {
        let optionVc = self.instantiateViewController(withIdentifier: T.storyboardId);

        guard let vc = optionVc as? T else {
            fatalError("Couldn’t create view controller with identifier \(T.storyboardId)");
        }

        return vc;
    }
}

extension UIViewController: StoryboardIdentifiable {
}
